/*  1:   */ package org.intellij.plugins.relaxNG.compact.psi.util;
/*  2:   */ 
/*  3:   */

import com.intellij.lang.ASTNode;
import com.intellij.psi.PsiElement;
import org.intellij.plugins.relaxNG.compact.RncTokenTypes;
import org.jetbrains.annotations.NotNull;

/*  4:   */
/*  5:   */
/*  6:   */
/*  7:   */ 
/*  8:   */ public class EscapeUtil
/*  9:   */ {
/* 10:   */   public static String unescapeText(@NotNull PsiElement paramPsiElement)
/* 11:   */   {
/* 12:32 */     if (paramPsiElement == null) {
/* 13:32 */       throw new IllegalArgumentException(String.format("Argument %s for @NotNull parameter of %s.%s must not be null", new Object[] { "0", "org/intellij/plugins/relaxNG/compact/psi/util/EscapeUtil", "unescapeText" }));
/* 14:   */     }
/* 15:32 */     ASTNode localASTNode = paramPsiElement.getNode();
/* 16:33 */     if (localASTNode != null) {
/* 17:34 */       return unescapeText(localASTNode);
/* 18:   */     }
/* 19:36 */     return paramPsiElement.getText();
/* 20:   */   }
/* 21:   */   
/* 22:   */   public static String unescapeText(@NotNull ASTNode paramASTNode)
/* 23:   */   {
/* 24:42 */     if (paramASTNode == null) {
/* 25:42 */       throw new IllegalArgumentException(String.format("Argument %s for @NotNull parameter of %s.%s must not be null", new Object[] { "0", "org/intellij/plugins/relaxNG/compact/psi/util/EscapeUtil", "unescapeText" }));
/* 26:   */     }
/* 27:42 */     String str = paramASTNode.getText();
/* 28:46 */     if (paramASTNode.getElementType() == RncTokenTypes.ESCAPED_IDENTIFIER)
/* 29:   */     {
/* 30:47 */       assert (str.charAt(0) == '\\');
/* 31:48 */       return str.length() > 1 ? str.substring(1) : "";
/* 32:   */     }
/* 33:50 */     return str;
/* 34:   */   }
/* 35:   */   
/* 36:   */   public static String parseLiteralValue(ASTNode paramASTNode)
/* 37:   */   {
/* 38:55 */     return a(unescapeText(paramASTNode));
/* 39:   */   }
/* 40:   */   
/* 41:   */   private static String a(String paramString)
/* 42:   */   {
/* 43:59 */     if ((paramString.length() >= 6) && (paramString.charAt(0) == paramString.charAt(1)))
/* 44:   */     {
/* 45:60 */       paramString = paramString.replace('\000', '\n');
/* 46:61 */       return paramString.substring(3, paramString.length() - 3);
/* 47:   */     }
/* 48:63 */     return paramString.substring(1, paramString.length() - 1);
/* 49:   */   }
/* 50:   */ }



/* Location:           E:\idea\

 * Qualified Name:     org.intellij.plugins.relaxNG.compact.psi.util.EscapeUtil

 * JD-Core Version:    0.7.0.1

 */